﻿$("#Main").datagrid({
    url: "/Admin/Guestbook/GetList",
    fit: true,
    fitColumns: true,
    striped: true,
    rownumbers: true,
    remoteSort: false,
    singleSelect: true,
    idField: "ID",
    columns: [[{
        title: "标题",
        field: "Title",
        width: 20
    }, {
        title: "姓名",
        field: "Name",
        width: 10
    }, {
        title: "联系方式",
        field: "Contact",
        width: 10
    }, {
        title: "是否显示",
        field: "ShowFlag",
        width: 6,
        formatter: function (value, row, index) {
            return value ? "是" : "否";
        }
    }, {
        title: "留言IP",
        field: "IP",
        width: 10
    }, {
        field: 'action',
        title: '编辑',
        width: 12,
        align: 'center',
        formatter: function (value, row, index) {
            return '<a href="#" onclick="view(' + row.ID + ')">查看</a>&nbsp;|&nbsp;<a href="#" onclick="del(' + row.ID + ')">删除</a>';
        }
    }]]
});
function view(id) {
    location.href = "/Admin/Guestbook/Detail/" + id + "?current=8&r=" + Math.random();
}
function del(id) {
    $.messager.confirm('警告', '确定删除?', function (r) {
        if (r)
            location.href = "/Admin/Guestbook/Delete/" + id + "?current=8&r=" + Math.random();
    });
}